package com.wty.cmims.controller;


import com.wty.cmims.pojo.Orders;
import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.OrdersService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/orders")
@Tag(name = "订单信息", description = "社区医疗信息管理系统api接口")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    // 订单信息获取
    @PostMapping("/add")
    @Operation(summary = "订单信息获取", description = "订单信息获取")
    @Parameter(name = "order",description = "订单信息")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Orders> ordersAdd(@RequestBody Orders orders){
        return ordersService.ordersAdd(orders);
    }

    // 订单状态修改
    @PostMapping("/update")
    @Operation(summary = "订单状态修改", description = "订单状态修改")
    @Parameter(name = "id",description = "订单ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> ordersStatusUpdate(@RequestParam(name = "id") Integer id){
        return ordersService.ordersStatusUpdate(id);
    }

    // 购药记录查询
    @PostMapping("/findOrdersHistoryRecord")
    @Operation(summary = "购药记录查询", description = "购药记录查询")
    @Parameter(name = "paramsMap",description = "查询条件")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> ordersHistoryRecordFind(@RequestBody Map<String,Object> paramsMap){
        return ordersService.ordersHistoryRecordFind(paramsMap);
    }
}